<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>在线统计</title>

    <link rel="stylesheet" type="text/css" th:href="@{/js/layui/css/layui.css/}" media="all">
    <link rel="stylesheet" type="text/css" th:href="@{/css/fyn/style.css/}" media="all">
    <link rel="stylesheet" type="text/css" th:href="@{/images/code.png}" media="all">
</head>
<body>

<div class="login-main">
    <header class="layui-elip">在线统计数</header>

    <table class="layui-table">


        <tbody id="tb">


        </tbody>
    </table>

</div>

<script th:src="@{/js/layui/layui.all.js}"></script>
<script type="text/javascript" th:inline="javascript">
    layui.use(['form'], function () {

        // 操作对象
        var form = layui.form
            , $ = layui.jquery;

        var list = [];
        list.push({'name': '逸信', 'ip': '47.111.129.48', 'count': '0'});
        list.push({'name': '乐聊', 'ip': '47.107.90.151', 'count': '0'});
        list.push({'name': '微聊', 'ip': '47.106.34.37', 'count': '0'});
        list.push({'name': '微聊招', 'ip': '47.111.177.232', 'count': '0'});
        list.push({'name': '彩聊', 'ip': '47.106.64.136', 'count': '0'});
        list.push({'name': '天网', 'ip': 'im.tienwangchat.com', 'count': '0'});
        list.push({'name': '互聊', 'ip': '47.56.161.157', 'count': '0'});
        list.push({'name': '掌上聊', 'ip': '47.96.77.15', 'count': '0'});
        list.push({'name': '众聊', 'ip': '121.40.114.102', 'count': '0'});
        list.push({'name': '滴聊', 'ip': '47.52.171.30', 'count': '0'});
        list.push({'name': '书信', 'ip': '39.108.143.159', 'count': '0'});
        list.push({'name': '维炫', 'ip': '222.186.48.10', 'count': '0'});

        for (var i = 0; i < list.length; i++) {
            request(list[i]);
        }


        function request(d) {
            $.ajax({
                url: "http://" + d.ip + ":8016/admin/login/count",
                success: function (data) {

                    if (data.success) {
                        // d.count = data.data;
                        $("#tb").append("<tr>\n" +
                            "            <td>" + d.name + "</td>\n" +
                            "            <td>" + data.data + "</td>\n" +
                            "        </tr>")
                    } else {
                        $("#tb").append("<tr>\n" +
                            "            <td>" + d.name + "</td>\n" +
                            "            <td>统计异常</td>\n" +
                            "        </tr>")

                    }
                }
                ,error:function(xhr,state,errorThrown){
                    $("#tb").append("<tr>\n" +
                        "            <td>" + d.name + "</td>\n" +
                        "            <td>访问失败</td>\n" +
                        "        </tr>")                }
            });
        }
        // console.log(list)


    });
</script>
</body>
</html>